package org.iteam.xlz.manager.action.message;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.iteam.web.struts.action.AbstractModuleAction;
import org.iteam.web.struts.action.RestAction;
import org.iteam.xlz.core.entity.messages.Feedback;
import org.iteam.xlz.core.service.message.FeedbackService;

@SuppressWarnings("unchecked")
@Results({@Result(name="INDEX",type="freemarker",location="/WEB-INF/content/message/feedback/index.html"),
		  @Result(name="EDIT",type="freemarker",location="/WEB-INF/content/message/feedback/edit.html")})
public class FeedbackAction extends AbstractModuleAction<Feedback> implements RestAction{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1019666533939274038L;
	private final String PATH="/message/feedback";
	
	@Override
	public Feedback getModel() {
		if(null==model){
			model=new Feedback();
		}
		return model;
	}
	
	@Override
	@Action(PATH+"/index")
	public String index() {
		return INDEX;
	}

	@Override
	@Action(PATH+"/query")
	public String query() {
		map.put("total",FeedbackService.getInstance().counts(mobile,leftCreateTime,rightCreateTime,type,tid));
		map.put("rows", FeedbackService.getInstance().query(mobile,leftCreateTime,rightCreateTime,type,tid,page,rows));
		return MAP;
	}

	@Override
	@Action(PATH+"/create")
	public String create() {
		return null;
	}

	@Override
	@Action(PATH+"/reply")
	public String update(){
		return null;
	}

	@Override
	public String delete() {
		return null;
	}

	@Override
	public String destroy() {
		return null;
	}

	@Override
	@Action(PATH+"/{_id}/edit")
	public String edit() {
		Feedback feedback = FeedbackService.getInstance().getFeedbackById(_id);
		object=feedback;
		array = feedback.getImagUlrs();
		return EDIT;
	}

	@Override
	public String editNew() {
		return null;
	}
	
	private String mobile;
	private String leftCreateTime;
	private String rightCreateTime;
	private String type;
	private String tid;

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public void setLeftCreateTime(String leftCreateTime) {
		this.leftCreateTime = leftCreateTime;
	}

	public void setRightCreateTime(String rightCreateTime) {
		this.rightCreateTime = rightCreateTime;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getTid() {
		return tid;
	}

	public void setTid(String tid) {
		this.tid = tid;
	}

	@Override
	public String show() {
		return null;
	}	
}
